

<style>
.layui-table-cell{padding:1px 2px;text-align:center;font-size:14px;line-height:28px;}
.layui-form-pane .layui-form-label{width:auto;}
.layui-form-item{margin-bottom: 0px;}
.fixed-bar-tr-header{top:51px!important;}

</style>
<div class="fixed-bar">
<form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
<div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label">订单号</label>
        <div class="layui-input-inline">
          <input type="text" name="client_ordernum" lay-verify="" placeholder="输入订单号" class="layui-input">
        </div>
    </div>
    {if env('env_site') == 'riwei' }
    <div class="layui-inline">
        <label class="layui-form-label">客户单号</label>
        <div class="layui-input-inline">
            <input type="text" name="ext_id" lay-verify="" placeholder="输入客户单号" class="layui-input">
        </div>
    </div>
    {/if}
    <div class="layui-inline removeStat">
        <label class="layui-form-label">SKU</label>
        <div class="layui-input-inline">
          <input type="text" name="sku" lay-verify="" placeholder="输入SKU" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">订单状态</label>
        <div class="layui-input-inline">
            {:Form::select('order_status', '', ['' => '请选择', 1=>'未采购', 2=>'已采购', 3=>'已裁床', 4=>'已车缝', 5=>'已后整', 6=>'已出货', 7=>'已完成', 99=>'已废弃', 999=>'MES废除'], '', '')}
        </div>
    </div>

    <div class="layui-inline removeStat">
        <label class="layui-form-label">下单日期</label>
        <div class="layui-input-inline time_input">
          <input type="text" name="create_date_range" readonly="" id="create_date_range" lay-verify="" placeholder="选择下单日期" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">所属工厂</label>
        <div class="layui-input-inline">
            {:Form::select('factory_id', '', $factoryKV, '', '')}
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">断码筛选</label>
        <div class="layui-input-inline">
            {:Form::select('break_type', '', [''=>'全部','1'=>'正常','2'=>'将断码','3'=>'已断码'],'','')}
        </div>
    </div>
<!--    <div class="layui-inline">
        <label class="layui-form-label">裁数区间</label>
        <div class="layui-input-inline">
            {:Form::select('range', '', $rangeList, '', '')}
        </div>
    </div>-->
    <div class="layui-inline">
		<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
<!--        <button type="button" class="layui-btn layui-btn-primary hisi-export">导出</button>-->
		
	</div>
</div>
</form>
</div>
<!-- 进度统计 -->
    <div class="layui-collapse removeStat" lay-accordion  style="width: 100%!important;">
      <div class="layui-colla-item">
        <h2 class="layui-colla-title">数据统计</h2>
        <div class="layui-colla-content layui-show">
            <h3 style="color: red">注意：这里的统计是下单时间从2022.1.1开始的订单 </h3>
          <table class="layui-table">
            <thead>
              <tr>
                <th>裁数区间</th>
                <th>订单数量</th>
                <th>占比</th>
            <!--<th>损失金额</th>-->
              </tr>
            </thead>
            <tbody id="show_statis">
            </tbody>
          </table>
        </div>
      </div>
    </div>

<table id="dataTable"></table>
{include file="system@block/layui" /}

<script type="text/html" id="neadendtTpl">
    <div>{{d.omInfo.caichuang_t_neadend}}</div>
</script>

<script type="text/html" id="statis_datas">
    {{#  layui.each(d.data, function(kkk, vvv){ }}
        <tr>
            <td>{{vvv.range}}</td>
            <td>{{vvv.order_num}}</td>
            <td className="stat-allq-item">{{vvv.ratio}}</td>
<!--        <td>{{vvv.total_monkey}}</td>-->
        </tr>
    {{# }); }}
    <tr>
        <td>总计：</td>
        <td id="orderTotalnum">0</td>
        <td ></td>
<!--     <td id="TotalLose">0元</td>-->
    </tr>
</script>


<script type="text/html" id="stripTpl">
    <div>{{d.omInfo.caichuang_t_strip}}</div>
</script>

<script type="text/html" id="shrinkLengthTpl">
    <div>{{d.omInfo.shrink_length}}</div>
</script>
<script type="text/html" id="caiGouCountTpl">
    <div>{{d.omInfo.billing_caigou_count}}</div>
</script>
<script type="text/html" id="timeTpl">
    <div>{{layui.util.toDateString(d.caichuang_over_time * 1000)}}</div>
</script>
<script type="text/html" id="picTpl">
    <span class="lay-pic-container" src="{{d.pic}}">
        <img src="{{d.pic}}" class="lay-pic">
    </span>
</script>
<script type="text/html" id="skuTpl">
    <span class="copy-item">{{ d.sku }}</span>
</script>
<script type="text/html" id="caiChuangUserTpl">
    {{# if (d.caichuang_user_name!=null) { }}   
  		<div>{{d.caichuang_user_name.name}}</div>
    {{# } else { }}  
      
    {{# } }}                            
</script>
    
 <script type="text/html" id="caiChuangTypeTpl">
    {{# if (d.caichuang_type=='1') { }}   
  		手工裁剪
    {{# } else { }}  
      电脑裁剪
    {{# } }}  
</script>   
<script type="text/html" id="shiJiCount">
    {{# if (d.omInfo.caichuang_t_wheat_low_length=='' || d.omInfo.caichuang_t_wheat_low_length=='0.00' && d.omInfo.caichuang_t_wheat_height_length=='0.00') { }}   
  		<div>0.00</div>
    {{# } else { }}  
      <div>{{(d.omInfo.caichuang_t_wheat_low_length + d.omInfo.caichuang_t_wheat_height_length) (d.omInfo.caichuang_t_wheat_low_length + d.omInfo.caichuang_t_wheat_height_number) }}</div>
    {{# } }}                
    
</script>
<script type="text/html" id="shiCaiCountTpl">
    <div>{{d.omInfo.shicai_count}}</div>
</script>

<script type="text/html" title="" id="cOrderNumTpl">
    {{# if(d.break_code != ''){ }}
    <span class="red">{{ d.break_code }}</span>
    <br>
    {{# } }}
    <span class="copy-item">{{ d.client_ordernum }}</span> <span class="layui-badge layui-bg-orange">{{ layui.tool.formatOrderType(d.type) }}</span>
    <br>
    <span class="copy-item">{{ d.sku }}</span>
    <br>
           {{ d.status }}
    <br>
    {{ layui.util.toDateString(d.create_time * 1000) }}
    <br>
    {{ d.factory_name }}
</script>
<script  type="text/html" title="订单数" id="orderTpl">
    {{# for(var i in d.order_list.list){ }}
    {{# if(d.order_list.order_count>0){ }}
    <span>{{d.order_list.list[i].size_name }}</span>：{{d.order_list.list[i].order_count }}<br />
    {{# } }}
    {{# } }}
    <b>总数：</b>{{d.order_list.order_count}}
</script>
<script  type="text/html" title="实裁数" id="shicaiTpl">
    {{# for(var i in d.shicai_list.list){ }}
    {{# if(d.shicai_list.shicai_count>0){ }}
    <span>{{d.shicai_list.list[i].size_name }}</span>：{{d.shicai_list.list[i].shicai_count }}<br />
    {{# } }}
    {{# } }}
    <b>总数：</b>{{d.shicai_list.shicai_count}}
</script>
<script type="text/html" id="lengthTpl">
    {{# if(d.shrink_length > 0){ }}
            {{ d.shrink_length }}
    {{# } else if(d.checkcloth_length > 0){ }}
           {{ d.checkcloth_length }}
    {{# } }}
</script>
<script type="text/html" id="jiagong">
加工费： {{ d.cost_profit }}<br>
物料费： {{ d.material_cost_total }}<br>
   {{# if(d.bili !=0 ){ }}
    比例： 1：{{  d.bili }}<br>
   {{# } }}

</script>

<script type="text/javascript">

    layui.use(['opTable','table', 'jquery', 'tool', 'laydate', 'layer', 'form', 'formSelects','laytpl'], function() {
        var $ = layui.jquery;
         var formSelects = layui.formSelects,form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var laytpl = layui.laytpl;
        //数据统计弹窗操作start
        var where=where1="";
        var hreStr=window.location.search;
        if(hreStr.indexOf("stat") != -1){
            $(".removeStat").remove();
            where1=window.location.search+"&create_date_range="+$.cookie('r_create_date_range')+"&factory_id="+$.cookie('r_factory_id')+"&sku="+$.cookie('r_sku')+"&caichuang_type="+$.cookie('r_caichuang_type')+"&stat_type="+$.cookie('r_stat_type')+"&caichuang_user_name="+$.cookie('r_caichuang_user_name')+"&caichuang_over_date_range="+$.cookie('r_caichuang_over_date_range');
            where=where1+"&client_ordernum="+$.cookie('r_client_ordernum');
            $("#hisi-table-search").attr("action",where1);
        }else{
            where="?a=stat";
        }
        table.render({
            elem : '#dataTable'
            ,url : '{:url()}'+where
            ,page: true
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,cols : [[
                ,{field:'client_ordernum',title : '订单号/SKU/状态/下单', templet:'#cOrderNumTpl',width: 145}
                ,{field:'pic',title : '图片', templet:'#picTpl',width:80}
                ,{field:'material_dosage', title:'计划采购量',width:80,templet:function(d){return layui.tool.bcmul(d.material_dosage, d.quantity);}}
                ,{field:'shice_meters',title : '实测米数',width:80}
                ,{field:'shicai_meters',title : '实裁米数',width:70}
                ,{field:'order_list',title : '订单数', templet:'#orderTpl',width:120}
                ,{field:'shicai_count',title : '实裁数',templet:'#shicaiTpl',width:120}
                ,{field:'shicai_section',title : '裁数区间',width:80}
                ,{field:'delivery_count',title : '入仓数',width: 80}
                ,{field:'stock_num',title : '成衣入库数',width: 80}
                ,{field:'is_shangjia',title : '上下架状态',width: 120}
                ,{field:'beiliao',title : '是否备料',width: 70}
                ,{field:'chufan_time',title : '初返时间',width: 120}
                ,{field:'lose_money',title : '损失金额',width: 90}
                ,{field:'jiagong',title : '加工费/面料费比例',templet:'#jiagong',width: 150}
            ]]
             ,openType : 1
			,done: function(res, curr, count){
                $('#show_statis').html('');
                var content = laytpl($('#statis_datas').html()).render({data:res.Statis.list});
                $('#show_statis').prepend(content);
                $('#orderTotalnum').html(res.Statis.order_total_num);
                $('#TotalLose').html(res.Statis.total_lose);

				if (res.stat !== undefined) {
                    console.log(res.stat)
					var p = res.stat;
					var w = res.stat.detailWhere;
					$.cookie("r_client_ordernum",w.client_ordernum,{ path:"/" });
					$.cookie("r_create_date_range",w.create_date_range,{ path:"/" });
					$.cookie("r_factory_id",w.factory_id,{ path:"/" });
					$.cookie("r_caichuang_over_date_range",w.caichuang_over_date_range,{ path:"/" });
					$.cookie("r_stat_type",w.stat_type,{ path:"/" });
					$.cookie("r_caichuang_user_name",w.caichuang_user_name,{ path:"/" });
					$.cookie("r_sku",w.sku,{ path:"/" });
					$.cookie("r_caichuang_type",w.caichuang_type,{ path:"/" });
                    
					$('.stat-coc-item').html(p.caichuangOverCount);
                    $('.stat-allq-item').html(p.caichuangAllQuantity);
					$('.stat-aoc-item').html(p.acOverCount);
					$('.stat-anc-item').html(p.acNotCount);
					$('.stat-acNoCount-item').html(p.acNoCount);

					$('.stat-aocp-item').html(p.acOverCountPer);
					$('.stat-ancp-item').html(p.acNotCountPer);
					$('.stat-acNoCountp-item').html(p.acNoCountPer);
				}
			}
        });
        
        laydate.render({
            elem: '#create_date_range'
            ,range: '~'
            ,theme: 'molv'
            ,min: '2022-1-1 00:00:00'
            ,mark: {'{:$today}':''}
            ,change: function(value, date, endDate){
               $('#create_date_range').val(value);
	            $('#layui-laydate1').remove();//关闭面板
            }
        });

    });
</script>
